<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" 
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
  targetNamespace="Examples">
  
  <process id="setScriptVariableThroughExecution" isExecutable="true">
  
    <startEvent id="theStart" />
    
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theScriptTask" />
    
    <scriptTask id="theScriptTask" name="Execute script" scriptFormat="groovy">
      <script>
        // Using def in Groovy makes the variable script-local
        // It will not be stored autmatically (which is the case when not using def)
        def scriptVar = "test123"
        execution.setVariable("myVar", scriptVar)
      </script>
    </scriptTask>

    <sequenceFlow id="flow2" sourceRef="theScriptTask" targetRef="theTask" />

    <userTask id="theTask" name="my task" />
    
     <sequenceFlow id="flow3" sourceRef="theTask" targetRef="theEnd" />
    
    <endEvent id="theEnd" />
    
  </process>

</definitions>